import sys

nums = [2, 7, 9, 3, 1]

size = len(nums)
# 存储前n天可以获得的最大收益
res = []

if size == 0:
    print(0)
    sys.exit(0)

if size == 1:
    print(nums[0])
    sys.exit(0)

if size > 1:
    res.append(nums[0])
    res.append(max(nums[0], nums[1]))

for i in range(1, size):
    res.append(max(res[i - 1], res[i] + nums[i - 1]))

print(nums[size - 1])
